﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.Practices.Unity;
using Vit.Common;
using Vit.Web.Mvc;
using Vit.Web.Helpers;

namespace Vit.Web.Modules
{
    public abstract class AreaModuleBase : AreaRegistration, IModule
    {
        public string Name { get { return AreaName; } }
        public string Title { get; set; }
        public string Description { get; set; }
        public string Logo { get; set; }
        public Version Version { get; set; }
        public string Licence { get; set; }
        public string ReleaseNote { get; set; }
        public DateTime ReleaseDate { get; set; }
        public string Owner { get; set; }
        public string Organization { get; set; }
        public string SiteUrl { get; set; }
        public string Email { get; set; }
        public decimal? Fee { get; set; }
        public string Theme { get; set; }
        public string Skin { get; set; }

        #region IModule Members

        public virtual bool OnInstalling(object sender, ModuleEventArg e, out string message)
        {
            message = string.Empty;
            return true;
        }

        public virtual bool OnInstalled(object sender, ModuleEventArg e, out string message)
        {
            message = string.Empty;
            return true;
        }

        public virtual bool OnUpdating(object sender, ModuleEventArg e, out string message)
        {
            message = string.Empty;
            return true;
        }

        public virtual bool OnUpdated(object sender, ModuleEventArg e, out string message)
        {
            message = string.Empty;
            return true;
        }

        public virtual bool OnUnInstalling(object sender, ModuleEventArg e, out string message)
        {
            message = string.Empty;
            return true;
        }

        public virtual bool OnUnInstalled(object sender, ModuleEventArg e, out string message)
        {
            message = string.Empty;
            return true;
        }

        public virtual bool OnPackaging(object sender, ModuleEventArg e, out string message)
        {
            message = string.Empty;
            return true;
        }

        public virtual bool OnUnPackaging(object sender, ModuleEventArg e, out string message)
        {
            message = string.Empty;
            return true;
        }

        public virtual void OnApplicationStart(HttpApplication application, IUnityContainer unity)
        {
            PortalHelper.RegisterWidgets(this.GetType().Assembly, AreaName);
        }

        public virtual void OnApplicationEnd(HttpApplication application, IUnityContainer unity)
        {
        }

        public virtual void OnSessionStart(HttpApplication application, IUnityContainer unity)
        {
        }

        public virtual void OnSessionEnd(HttpApplication application, IUnityContainer unity)
        {
        }

        public virtual void OnBeginRequest(HttpApplication application, IUnityContainer unity)
        {
        }

        public virtual void OnEndRequest(HttpApplication application, IUnityContainer unity)
        {
        }

        #endregion
    }
}
